@extends('Home/Layout/base_login_resgister')

@section('title', '重置密码页面')

@section('main')

    <div class="main-wrap">
        <div class="wrapper">
            <div class="center-box">
                <form action="" method="">
                    <div class="box-hd">
                        <span class="tit">重置密码</span>
                    </div>
                    <label class="txtin-box">
                        <input id='checkpwd' class="txtin" type="password" name="pwd" placeholder="输入密码" />
                    </label>
                    <label class="txtin-box">
                        <input id='confirmPwd' class="txtin" type="password" name="confirmPwd" placeholder="确认密码" />
                    </label>

                    <input class="tj" type="button" value="完&ensp;成" />

                </form>
            </div>
        </div>
    </div>
@endsection

@section('footer-js')
<script>
    $('.tj').on('click', function() {
        var uModifycondition = '{{$Modifycondition}}';
        var upwd = $('input[name="pwd"]').val();
        var uconfirmPwd = $('input[name="confirmPwd"]').val();

        $.axpost(
            'post',
            '{{url("/doresetpwd")}}',
            'Modifycondition='+uModifycondition+'&pwd='+upwd+'&confirmPwd='+uconfirmPwd+'&_token={{csrf_token()}}',
            function(data) {

                if (data.status==1401) {

                    layer.tips(data.msg, '#confirmPwd', {tips:[2, '#FF0000']});
                }

                if (data.status==1400) {

                    layer.alert(data.msg, {icon:5});
                }

                if (data.status==1200) {

                    layer.alert(data.msg, {icon:6});
                    location.href = '{{url("/login")}}';
                }
            },

            function(tipString) {

                if (tipString.responseText) {

                    var tipObj = JSON.parse(tipString.responseText).errors;

                    if (tipObj['pwd']) {
                        layer.tips(tipObj['pwd'], '#checkpwd', {
                            tips:[2, '#FF0000'],
                            tipsMore: true
                        });
                    }

                    if (tipObj['confirmPwd']) {
                        layer.tips(tipObj['confirmPwd'], '#confirmPwd', {
                            tips:[2, '#FF0000'],
                            tipsMore: true
                        });
                    }
                }
            }

        );

    });

</script>

@endsection
